package edu.zzuli.common;

import edu.zzuli.test.pojo.User;
import org.springframework.web.servlet.HandlerInterceptor;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;


/**
 * Created by Chen-D.W on 2017/12/23.
 */
public class LoginController implements HandlerInterceptor {

    @Override
    public boolean preHandle(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, Object o) throws Exception {
//        String url=httpServletRequest.getRequestURI();
//        if(url.indexOf("login")>=0||url.indexOf("mailServlet")>=0){
//            return true;
//        }
//        HttpSession session=httpServletRequest.getSession();
//        User user= (User) session.getAttribute("userInf");
//        if(user!=null){
//            return true ;
//        }else {
//            httpServletRequest.getRequestDispatcher("/login.html").forward(httpServletRequest,httpServletResponse);
//        }
//        return false;
        return true;
    }

    @Override
    public void postHandle(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, Object o, ModelAndView modelAndView) throws Exception {

    }

    @Override
    public void afterCompletion(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, Object o, Exception e) throws Exception {

    }
}
